<template>
<div>
    <HomeHeader :type_="type_"></HomeHeader>
    <v-content>
        <v-container ><v-card>
            <v-data-table
                    :headers="items"
                    :items="getdata"
                    :items-per-page="5"
            ></v-data-table>
            <v-btn rounded color="primary" dark @click="_getdepname">添加</v-btn>
            <v-dialog v-model="show" max-width="500px">
                <v-card>
                    <v-card-title>
                        <span class="headline">添加医生</span>
                    </v-card-title>
                    <v-card-text>
                        <v-container>
                            <v-row>
                                <v-col cols="12" sm="6" md="4" v-for="(item,i) in itemwin" :key="i">

                                    <v-overflow-btn
                                            v-if= item.select
                                            class="my-2"
                                            :items="department"
                                            :label="item.text"
                                            item-text="dep_name"
                                            item-value="dep_id"
                                            v-model="setdata.dep_id"
                                    ></v-overflow-btn>
                                    <v-text-field v-else :label="item.text" v-model="setdata[item.value]"></v-text-field>
                                </v-col>
                            </v-row>
                        </v-container>
                    </v-card-text>
                    <v-card-actions>
                        <v-spacer></v-spacer>
                        <v-btn color="blue darken-1" text @click="show=!show">取消</v-btn>
                        <v-btn color="blue darken-1" text @click="_adddoctor">提交</v-btn>
                    </v-card-actions>
                </v-card>
            </v-dialog>
        </v-card></v-container >
    </v-content>
    <Home-Footer :type_="type_"></Home-Footer>
  </div>
</template>
<script>
  export default {
  data() {
    return {
        type_:"adm",
        show:false,
        items:[{text:"科室ID",value:'dep_id'},{text:"科室",value:'dep_name'},{text:"医生ID",value:'doc_id'},{text:"医生姓名",value:'doc_name'}],
        itemwin:[{text:"科室",value:'dep_name',select:1},{text:"医生ID",value:'doc_id'},{text:"医生姓名",value:'doc_name'}],
        setdata:{
            dep_id:'',
            doc_id:'',
            doc_name:'',
        },
        getdata:[],
        department:[]
    }
  },methods: {
          _getdepname(){
              this.show=!this.show
              var params ={_option:'1024'}
              this.$http.post(params,2).then((res)=>{
                  let { resultCode, resultObject, resultMsg } = res
                  if (resultCode === '0') {
                      if (resultObject) {
                                this.department=resultObject.dataList
                      } else {
                          this.department=[]
                      }
                  } else {
                      this.department=[]
                      this.response=resultMsg
                  }
              })
          },
_adddoctor(){
    var params=this.setdata
    params._option='1003'
    this.$http.post(params,2).then((res)=>{
        this.response=res
        this.show=!this.show
        this._begin()
    }).catch((err)=>{
        this.response=err
    })
},_begin(){
      var params ={_option:'1013'}
      this.$http.post(params,2).then((res)=>{
          let { resultCode, resultObject, resultMsg } = res
          if (resultCode === '0') {
              if (resultObject) {
                  this.getdata = resultObject.dataList
              } else {
                  this.getdata = []
              }
          } else {
              this.getdata = []
              this.response=resultMsg
          }
      })
  }
  }
      ,mounted() {
this._begin()
      }
  }
</script>


<style  scoped>
</style>
